package com.ruoyi.project.registration.controller;

import com.ruoyi.common.core.lang.UUID;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.registration.domain.RegDisease;
import com.ruoyi.project.registration.service.RegDiseaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/registration/regDisease")
public class RegDiseaseController extends BaseController {
    @Autowired
    private RegDiseaseService regDiseaseService;

    /**
     * 新增病例
     * */
    @PreAuthorize("@ss.hasPermi('registration：regDisease:add')")
    @Log(title = "看病就诊", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult addRegDisease(RegDisease regDisease){

        regDisease.setCreateBy(SecurityUtils.getUsername());
        //使用UUID生成病例单号
        regDisease.setReDisId(UUID.randomUUID().toString());

        return toAjax(regDiseaseService.insertRegDisease(regDisease));
    }

}
